import { createApp } from "vue";
import ElementPlus from "element-plus";
import { createRouter, createWebHashHistory } from "vue-router";
import * as ElIcons from "@element-plus/icons-vue";
import App from "./App.vue";
import "element-plus/theme-chalk/index.css";
import routes from "./router";

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

const app = createApp(App);
app.use(ElementPlus);
/* 添加icon */
for (const name in ElIcons) {
  app.component(transElIconName(name), ElIcons[name]);
}
/* 添加router */
app.use(router);
app.mount("#app");

// 使用图标，格式i-icon-name，例如：<i-arrow-down />
function transElIconName(iconName) {
  return "icon" + iconName.replace(/[A-Z]/g, (match) => "-" + match.toLowerCase());
}
